﻿Public Class frmPostVentas

    Private Sub frmPostVentas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 0 To 100
            cboLoteNum.Items.Add(i)
        Next i
        puntajeTotal = 0
        CargarEmpresas(cbo_empresa)
        CargarAuditor(cbo_controla)
        CargarTllamada(cbo_tllamada)
        CargarOptSaluPVta(cbo_salu)
        CargarOptEmpaPVta(cbo_empatia)
        CargarOptEscPVta(cbo_indagacion)
        CargarOptIndPVta(cbo_disposicion)
        CargarOptDisPVta(cbo_compromiso)
        CargarOptPresPVta(cbo_info)
        CargarOptComPVta(cbo_comunicacion)
        CargarOptCierPVta(cbo_credibilidad)
        dtp_hoy.Value = Today
        lbl_puntaje.Text = puntajeTotal
        Limpiar(Gb_01)
        TodoACero()
    End Sub
    Private Sub bt_guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_guardar.Click
        Dim controles As String
        controles = ""
        controles = ControlCamposIncompletos(Gb_01) + controles
        controles = ControlCamposIncompletos(Gb_03) + controles

        If controles <> "" Then
            MsgBox("Le falto completar datos en: " & Chr(13) & controles, MsgBoxStyle.Critical, "ERROR!")
        Else
            Dim myfecha As Date
            myfecha = Now
            lblIdunicoLlam.Text = myfecha.ToString("hhmmssMMddyyyy")
            Dim guardar As New C_agregarDatosPostVentas
            guardar.guardarLLamada()
            Psaludo = 0
            Pempatia = 0
            Pindagacion = 0
            Pdisposicion = 0
            Pcompromiso = 0
            Pinformacion = 0
            Pcomunicacion = 0
            Pcierre = 0
            lbl_puntaje.Text = 0
            TodoACero()
        End If
    End Sub
    Private Sub bt_nAuditado_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmNewAuditado.ShowDialog()
    End Sub
    Private Sub bt_nControler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmNewControlador.ShowDialog()
    End Sub
    Private Sub cbo_salu_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_salu.SelectedIndexChanged
        Dim valorSal As New C_todosPostVentas
        Psaludo = valorSal.valorSalu()
        txtv01.Text = Psaludo
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub cbo_empatia_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_empatia.SelectedIndexChanged
        Dim valorEmp As New C_todosPostVentas
        Pempatia = valorEmp.valorEmpatia()
        txtv02.Text = Pempatia
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub cbo_indagacion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_indagacion.SelectedIndexChanged
        Dim valorInd As New C_todosPostVentas
        Pindagacion = valorInd.valorEscucha()
        txtv03.Text = Pindagacion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub cbo_disposicion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_disposicion.SelectedIndexChanged
        Dim valorDisp As New C_todosPostVentas
        Pdisposicion = valorDisp.valorIndagacion()
        txtv04.Text = Pdisposicion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub cbo_compromiso_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_compromiso.SelectedIndexChanged
        Dim valorComp As New C_todosPostVentas
        Pcompromiso = valorComp.valorDisposicion()
        txtv05.Text = Pcompromiso
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub cbo_info_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_info.SelectedIndexChanged
        Dim valorinf As New C_todosPostVentas
        Pinformacion = valorinf.valorPrecision()
        txtv06.Text = Pinformacion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub cbo_comunicacion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_comunicacion.SelectedIndexChanged
        Dim valorComunic As New C_todosPostVentas
        Pcomunicacion = valorComunic.valorComunicacion()
        txtv07.Text = Pcomunicacion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub cbo_credibilidad_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_credibilidad.SelectedIndexChanged
        Dim valorCredi As New C_todosPostVentas
        Pcredibilidad = valorCredi.valorCierre()
        txtv08.Text = Pcredibilidad
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub LlamadasPorNºDeLoteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmInfoAsesorAtencion.ShowDialog()
    End Sub
    Private Sub bt_nEmpresa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frm_empresa.ShowDialog()
    End Sub
    Private Sub cbo_empresa_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_empresa.SelectedIndexChanged
        auditadosXempresaVentas(cbo_auditado, cbo_empresa.Text)
    End Sub
    Private Sub dtp_fllam_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtp_fllam.ValueChanged
        If dtp_fllam.Value > Today Then
            MsgBox("La fecha de llamada no puede ser mayor al día Actual")
            dtp_fllam.Value = Today
        End If
    End Sub
    Private Sub EditarLlamadasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmEditarLlamadas.ShowDialog()
    End Sub
    Private Sub RankingDePromediosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmInfoRankingAtencion.ShowDialog()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim yes As Integer
        yes = MsgBox("Seguro desea Volver de este formulario de Ventas?" & Chr(13) & "Los datos se perderan al no ser guardados", MsgBoxStyle.YesNo, "Volver")
        If yes = 6 Then
            TodoACero()
            Close()
        End If
    End Sub
    Private Sub TodoACero()
        Limpiar(Gb_01)
        Limpiar(Gb_02)
        Limpiar(Gb_03)
        Limpiar(gbValores)

    End Sub
End Class